package com.z.common.job.controller;

import com.github.pagehelper.PageInfo;
import com.z.common.job.entity.ScheduleLog;
import com.z.common.job.service.IScheduleLogService;
import com.z.common.web.base.BaseController;
import com.z.common.web.vo.request.PageVo;
import com.z.common.web.vo.response.Result;
import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

/**
 * Describe: 定时任务日志控制器
 * Author: 就眠仪式
 * createTime: 
 */
@RestController
@Api(tags = {"任务日志"})
@RequestMapping("/system/job/log")
public class ScheduleLogController extends BaseController {

    /**
     * Describe: 定时任务日志服务
     */
    @Resource
    private IScheduleLogService scheduleLogService;

    /**
     * Describe: 获取定时任务日志列表视图
     * Param: modelAndView
     * Return: 定时任务日志列表视图
     */
    @GetMapping("main")
    @PreAuthorize("hasPermission('/system/job/main','sch:job:main')")
    public ModelAndView main() {
        return jumpPage("system/job/job");
    }

    /**
     * Describe: 获取定时任务日志列表数据
     * Param: PageDomain
     * Return: Result
     */
    @GetMapping("data")
    @PreAuthorize("hasPermission('/system/job/data','sch:job:main')")
    public Result data(ScheduleLog scheduleLogBean, PageVo pageDomain) {
        PageInfo<ScheduleLog> pageInfo = scheduleLogService.page(scheduleLogBean, pageDomain);
        return Result.table(pageInfo);
    }
}
